#include <iostream>
#include <vector>

using namespace std;

vector<int> mat[10005];

int main()
{
	int n, m, x, y;
	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		cin >> x >> y;
		mat[x].push_back(y);
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < mat[i].size(); j++) {
			if(j != mat[i].size() - 1) {
				cout << mat[i][j] << " ";
			} else {
				cout << mat[i][j] << endl;
			}
		}
		cout << "\n";
	}

	return 0;
}